#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool isValid(char *s){
	char stack[1000];
	int top = -1;
	for (int i=0;i<strlen(s);i++) {
		if(s[i] == '(' || s[i] == '[' || s[i] == '{'){
			stack[++top] = s[i];
		}
		else if((s[i] == ')' || s[i] == ']' || s[i] == '}') && top == -1)
			return false;
		else if (s[i] == ')'){
			if(stack[top] == '('){
				stack[top] = '\0';
				if(top >= 0){
					top--;
				}
			}
			else {
				return false;
			}
			
		}
		else if (s[i] == ']'){
//			printf("top = %c",stack[top]);
			if(stack[top] == '['){
				stack[top] = '\0';
				if(top >= 0){
					top--;
				}
			}
			else {
				return false;
			}
		}
		else if (s[i] == '}'){
			if(stack[top] == '{'){
				stack[top] = '\0';
				if(top >= 0){
					top--;
				}
			}
			else {
				return false;
			}
		}
	}
	if(top == -1){
		return true;
	}
//	printf("%s\n",s);
	return false;
}
int main(int argc, char *argv[]) {
	char buffer[50];
	while(scanf("%s",buffer)!=EOF){
		if(isValid(buffer)){
			printf("true\n");
		}
		else {
			printf("false\n");
		}
	}
}